package com.iptv.grape;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.iptv.grape.ui.BaseFrgmt;
import com.iptv.grape.ui.frgmt.my.AccountInfoFrgmt;
import com.iptv.grape.ui.frgmt.my.GarbageCleanFrgmt;
import com.iptv.grape.ui.frgmt.my.NetSettingFrgmt;
import com.iptv.grape.ui.frgmt.my.NetTestFrgmt;
import com.iptv.grape.ui.frgmt.my.OneKeySpeedUpFrgmt;
import com.iptv.grape.ui.frgmt.my.SystemInfoFrgmt;

public class MyAct extends BaseAct {
    @Override
    protected int layout() {
        return R.layout.act_my;
    }

    @Override
    protected void initView() {
        String tag = getIntent().getStringExtra("TYPE");
        BaseFrgmt mFrgmt=null;
        switch (tag){
                case "PlayLocally"://本地消息
                    break;
                case "Account": //账号管理
                    mFrgmt =new AccountInfoFrgmt();
                    break;
                case "Bill": // 我的账单
                    break;
                case "AppManagement"://应用管理

                    break;
                case "SystemInfo"://系统信息
                    mFrgmt =new SystemInfoFrgmt();
                    break;
                case "NetworkSettings": //网络设置
                    mFrgmt =new NetSettingFrgmt();
                    break;
                case "SpeedUp": // 一键加速
                    mFrgmt =new OneKeySpeedUpFrgmt();
                    break;
                case "NetworkTesting": // 网络测试
                    mFrgmt =new NetTestFrgmt();
                    break;
                case "WasteCleaning": //垃圾清理
                    mFrgmt =new GarbageCleanFrgmt();
                    break;

        }
        if(null!=mFrgmt){
            replace(mFrgmt);
        }
    }
    private void replace(Fragment fragment){
        String tag = fragment.getClass().getSimpleName();
        FragmentManager manager = this.getSupportFragmentManager();
        Fragment fm = manager.findFragmentByTag(tag);
        if(fm!=null&&fm==fragment){
            manager.beginTransaction().show(fragment).commit();
        }else{
            manager.beginTransaction().replace(R.id.flLayout,fragment,tag).commit();

        }

    }

}
